/*
 * cEntity.cpp
 *
 *  Created on: 26.04.2012
 *      Author: e_krais
 */

#include "cEntity.h"

namespace ants {

cEntity::cEntity() {
	m_x = 0;
	m_y = 0;
	m_w = 0;
	m_h = 0;

	m_spd = 5.0f;

	m_r = 1.0f;
	m_g = 1.0f;
	m_b = 1.0f;
	m_a = 1.0f;

	m_rotation = 0.0f;
	m_scale = 1.0f;

	m_curAnim = NULL;
}

cEntity::~cEntity() {
	m_anims.clear();
}

void cEntity::SetColor(float r, float g, float b, float a)
{
	if (r>=0)
		m_r = r;
	if (g>=0)
		m_g = g;
	if (b>=0)
		m_b = b;
	if (a>=0)
		m_a = a;
}

void cEntity::SetCurrentAnimation(const char* code)
{
	m_curAnim = m_anims[code];
}

void cEntity::AddAnimation(const char* code, cAnimation* anim)
{
	m_anims[code] = anim;
}

void cEntity::DeleteAnimation(const char* code)
{
	m_anims.erase(code);
}

void cEntity::DeleteAllAnimation()
{
	m_anims.clear();
}

void cEntity::Draw()
{
	if (m_curAnim != NULL)
	{
		m_curAnim->Draw(m_x, m_y, m_scale, m_rotation);
	}
}


}
